﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataLib.Accounts.Bus;

namespace Ewts.Storage
{
    public partial class RubbishDataList : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                //归属地
                ListItem item = new ListItem();
                item.Text = "--请选择--";
                item.Value = "";
                DataLib.BLL.City bllLib = new DataLib.BLL.City();
                dropBelong.DataSource = bllLib.GetList(" flag1='01'");
                dropBelong.DataTextField = "cityname";
                dropBelong.DataValueField = "cityname";
                dropBelong.DataBind();
                dropBelong.Items.Insert(0, item);


                BindData();
            }
        }

        protected void BindData()
        {
            reptRubbish.DataSource = new DataLib.BLL.LoadNum().GetLoadKH();
            reptRubbish.DataBind();
        }

        /// <summary>
        /// 返回参数
        /// </summary>
        /// <param name="rid">0新增</param>
        /// <returns></returns>
        protected string GetModePar(string rid)
        {

            if (rid == "0")
                return "add";
            else
                return "update";
        }

        /// <summary>
        /// 返回字符串
        /// </summary>
        /// <param name="lodnumid"></param>
        /// <returns></returns>
        protected string GetModeStr(string lodnumid)
        {
            DataLib.Model.RubbishData rubmodel = new DataLib.BLL.RubbishData().GetModelByLoad(int.Parse(lodnumid));
            if (rubmodel != null)
                return "修改";
            else
                return "添加";
        }

      
        /// 20130325 梁玲
        /// 取得业务员姓名
        protected string GetName(string saleman)
        {
            return new User(saleman).TrueName;
        }

        ///20130325 梁玲
        ///根据归属地查询结果
        protected void dropBelong_SelectedIndexChanged(object sender, EventArgs e)
        {
            string where="";
            if (dropBelong.SelectedValue!="" && dropBelong.SelectedValue!=null)
	        {
                where = " and belongarea ='" + dropBelong.SelectedValue + "'";
	        }
            reptRubbish.DataSource = null;
            reptRubbish.DataSource = new DataLib.BLL.LoadNum().GetLoadKHBywhere(where);
            reptRubbish.DataBind();
        }
    }
}